import type { IColumnsOption } from 'vc';
import { INDEX, COMPANY_NAME, BUSINESS_DATA, REGISTERED_CAPITAL, PROVINCE, CITY, COUNTRY, INDUSTRY_CATEGORY } from '@/utils/tableColumn';
import { setHrefUrlTool } from '@/utils';

export function useTable() {
  const columns = ref<IColumnsOption[]>([
    { ...INDEX },
    { ...COMPANY_NAME },
    {
      field: 'noticeDate',
      title: '披露日期',
      align: 'center',
      sortable: true,
      width: 110,
      sortBy: 'noticeDate'
    },
    {
      width: 280,
      field: 'attachments',
      title: '信息来源',
      slots: {
        default: ({ row }) => {
          return (
            <div>
              <a title={row.catalogueName} onClick={() => setHrefUrlTool(row.fileType, row.fileUrl)}>
                {row.catalogueName || '查看'}
              </a>
              <br />
            </div>
          );
        }
      }
    },
    {
      field: 'statisticalYear',
      title: '认定年度',
      align: 'center',
      sortable: true,
      width: 110,
      sortBy: 'statisticalYear'
    },
    {
      field: 'technology',
      title: '技术名称',
      sortable: true,
      width: 200,
      sortBy: 'technology',
      showOverflow: 'title'
    },
    {
      field: 'technologyApplicationRange',
      title: '适用范围',
      width: 200,
      cellRender: { name: 'Clamp' }
    },
    {
      field: 'technologyIntroduction',
      title: '技术内容',
      width: 200,
      cellRender: { name: 'Clamp' }
    },
    {
      field: 'issueAgency',
      title: '发布单位',
      sortable: true,
      width: 200,
      sortBy: 'issueAgency'
    },
    { ...PROVINCE },
    { ...CITY },
    { ...INDUSTRY_CATEGORY },
    { ...BUSINESS_DATA },
    { ...REGISTERED_CAPITAL }
  ]);

  return {
    columns
  };
}
